home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / misc / egs.lha / EGS / EGS_Devels / Examples / Other / star.c < prev    next >
C/C++ Source or Header  |  1993-02-17  |  3KB  |  102 lines

  1. /* star.c
  2. **
  3. ** FM - 12.08.92
  4. **
  5. ** Renders a colour flow in the shape of a star by using lines
  6. **
  7. **
  8. ** (c) by VIONA-Development 1992/93
  9. **
  10. */
  11.  
  12. #include <exec/types.h>
  13. #include <proto/exec.h>
  14. #include <egs/egsintui.h>
  15. #include <egs/proto/egsintui.h>
  16. #include <egs/egsgfx.h>
  17. #include <egs/proto/egsgfx.h>
  18. #include <egs/egs.h>
  19. #include <egs/proto/egs.h>
  20.  
  21.  
  22. /* the pointers to our libraries */
  23. struct Library *EGSIntuiBase;
  24. struct Library *EGSGfxBase;
  25. struct Library *EGSBase;
  26.  
  27.  
  28. /* Rendering of a regular star with four spikes */
  29. void drawStar8( EG_RastPortPtr rp, long mx, long my, long h1, long h2 )
  30. {
  31.         EG_AreaMove( rp, mx,    my-h1 );
  32.         EG_AreaDraw( rp, mx+h2, my-h2 );
  33.         EG_AreaDraw( rp, mx+h1, my    );
  34.         EG_AreaDraw( rp, mx+h2, my+h2 );
  35.         EG_AreaDraw( rp, mx,    my+h1 );
  36.         EG_AreaDraw( rp, mx-h2, my+h2 );
  37.         EG_AreaDraw( rp, mx-h1, my );
  38.         EG_AreaDraw( rp, mx-h2, my-h2 );
  39.         EG_AreaEnd( rp );
  40. }
  41.  
  42.  
  43. /* something's happening here */
  44. #define MAX_SIZE        100
  45.  
  46. void doThings( EI_WindowPtr window )
  47. {
  48.         long size;
  49.  
  50.         for( size=MAX_SIZE; size>1; size-- )
  51.                 {
  52.                 EG_SetAPen( window->RPort, ((255*size)/MAX_SIZE)*0x1010000 + 0x0000ff00 );
  53.                 drawStar8( window->RPort, window->Width/2,window->Height/2, MAX_SIZE,size );
  54.                 }
  55.         WaitPort( window->UserPort );
  56. }
  57.  
  58.  
  59. /* main program */
  60. void main( int argc, char *argv[] )
  61. {
  62.         static struct EI_NewWindow newWindow =
  63.                 {
  64.                 50,30, 400,300,
  65.                 0,0, 0,0,
  66.                 NULL,
  67.                 EI_WINDOWCLOSE | EI_WINDOWBACK | EI_WINDOWDRAG,
  68.                 NULL,
  69.                 "Testfenster",
  70.                 EI_SMART_REFRESH,
  71.                 EI_iCLOSEWINDOW,
  72.                 NULL,
  73.                 {0,0,0,0,0,0,0},
  74.                 NULL,
  75.                 NULL
  76.                 };
  77.     EI_WindowPtr window;
  78.  
  79.     /* open libraries */
  80.         EGSIntuiBase = OpenLibrary( (UBYTE *)"egsintui.library", 0 );
  81.         if ( EGSIntuiBase )
  82.                 {
  83.                 EGSGfxBase = OpenLibrary( (UBYTE *)"egsgfx.library", 0 );
  84.                 if ( EGSGfxBase )
  85.                         {
  86.                         EGSBase = OpenLibrary( (UBYTE *)"egs.library", 0 );
  87.                         if ( EGSBase )
  88.                                 {
  89.                         window = EI_OpenWindow( &newWindow );
  90.                     if ( window )
  91.                                 {
  92.                                 doThings( window );
  93.                                 EI_CloseWindow( window );
  94.                                 }
  95.                                 CloseLibrary( EGSBase );
  96.                                 }
  97.                 CloseLibrary( EGSGfxBase );
  98.                 }
  99.                 CloseLibrary( EGSIntuiBase );
  100.                 }
  101. }
  102.